﻿using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Data.SqlClient;

namespace SalePartial.Model
{
    public class XPUserProfileInfo
    {
        // Methods
        public XPUserProfileInfo()
        {
            this._jobTitle = string.Empty;
            this._familyName = string.Empty;
            this._firstName = string.Empty;
            this._officePhone = string.Empty;
            this._cellPhone = string.Empty;
            this._country = string.Empty;
            this._province = string.Empty;
            this._city = string.Empty;
            this._postCode = string.Empty;
            this._software = string.Empty;
            this._notificationCollection = string.Empty;
            this._userCollection = 1;
            this._isApprovedBuyer = false;
            this._isApprovedVendor = false;
            this._notificationEnabled = true;
        }

        public XPUserProfileInfo(SqlDataReader reader)
        {
            this._jobTitle = string.Empty;
            this._familyName = string.Empty;
            this._firstName = string.Empty;
            this._officePhone = string.Empty;
            this._cellPhone = string.Empty;
            this._country = string.Empty;
            this._province = string.Empty;
            this._city = string.Empty;
            this._postCode = string.Empty;
            this._software = string.Empty;
            this._notificationCollection = string.Empty;
            this.LoadFromReader(reader);
        }

        //public XPUserProfileInfo(Guid id)
        //{
        //    this._jobTitle = string.Empty;
        //    this._familyName = string.Empty;
        //    this._firstName = string.Empty;
        //    this._officePhone = string.Empty;
        //    this._cellPhone = string.Empty;
        //    this._country = string.Empty;
        //    this._province = string.Empty;
        //    this._city = string.Empty;
        //    this._postCode = string.Empty;
        //    this._software = string.Empty;
        //    this._notificationCollection = string.Empty;
        //    SqlDataReader reader = XPUserProfileUtility.SelectReader(id);
        //    if (reader.Read()) {
        //        this.LoadFromReader(reader);
        //        reader.Close();
        //    } else {
        //        if (!reader.IsClosed) {
        //            reader.Close();
        //        }
        //        throw new ApplicationException("XPUserProfile does not exist.");
        //    }
        //}

        protected void LoadFromReader(SqlDataReader reader)
        {
            if ((!Information.IsNothing(reader) && !reader.IsClosed))
            {
                this._userID = reader.GetGuid(0);
                if (!reader.IsDBNull(1))
                {
                    this._jobTitle = reader.GetString(1);
                }
                this._familyName = reader.GetString(2);
                this._firstName = reader.GetString(3);
                if (!reader.IsDBNull(4))
                {
                    this._officePhone = reader.GetString(4);
                }
                if (!reader.IsDBNull(5))
                {
                    this._cellPhone = reader.GetString(5);
                }
                if (!reader.IsDBNull(6))
                {
                    this._country = reader.GetString(6);
                }
                if (!reader.IsDBNull(7))
                {
                    this._province = reader.GetString(7);
                }
                if (!reader.IsDBNull(8))
                {
                    this._city = reader.GetString(8);
                }
                if (!reader.IsDBNull(9))
                {
                    this._postCode = reader.GetString(9);
                }
                this._software = reader.GetString(10);
                this._userCollection = reader.GetInt16(11);
                this._isApprovedVendor = reader.GetBoolean(12);
                this._isApprovedBuyer = reader.GetBoolean(13);
                this._notificationEnabled = reader.GetBoolean(14);
                if (!reader.IsDBNull(15))
                {
                    this._notificationCollection = reader.GetString(15);
                }
            }
        }

        public static XPUserProfileInfo NewXPUserProfile(Guid id)
        {
            return new XPUserProfileInfo { _userID = id };
        }

        // Properties
        public string CellPhone
        {
            get { return this._cellPhone; }
            set { this._cellPhone = value; }
        }

        public string City
        {
            get { return this._city; }
            set { this._city = value; }
        }

        public string Country
        {
            get { return this._country; }
            set { this._country = value; }
        }

        public string FamilyName
        {
            get { return this._familyName; }
            set { this._familyName = value; }
        }

        public string FirstName
        {
            get { return this._firstName; }
            set { this._firstName = value; }
        }

        public bool IsApprovedBuyer
        {
            get { return this._isApprovedBuyer; }
            set { this._isApprovedBuyer = value; }
        }

        public bool IsApprovedVendor
        {
            get { return this._isApprovedVendor; }
            set { this._isApprovedVendor = value; }
        }

        public string JobTitle
        {
            get { return this._jobTitle; }
            set { this._jobTitle = value; }
        }

        public string NotificationCollection
        {
            get { return this._notificationCollection; }
            set { this._notificationCollection = value; }
        }

        public bool NotificationEnabled
        {
            get { return this._notificationEnabled; }
            set { this._notificationEnabled = value; }
        }

        public string OfficePhone
        {
            get { return this._officePhone; }
            set { this._officePhone = value; }
        }

        public string PostCode
        {
            get { return this._postCode; }
            set { this._postCode = value; }
        }

        public string Province
        {
            get { return this._province; }
            set { this._province = value; }
        }

        public string Software
        {
            get { return this._software; }
            set { this._software = value; }
        }

        public short UserCollection
        {
            get { return this._userCollection; }
            set { this._userCollection = value; }
        }

        public Guid UserID
        {
            get { return this._userID; }
            set { this._userID = value; }
        }


        // Fields
        private string _cellPhone;
        private string _city;
        private string _country;
        private string _familyName;
        private string _firstName;
        private bool _isApprovedBuyer;
        private bool _isApprovedVendor;
        private string _jobTitle;
        private string _notificationCollection;
        private bool _notificationEnabled;
        private string _officePhone;
        private string _postCode;
        private string _province;
        private string _software;
        private short _userCollection;
        private Guid _userID;
    }
}

